<template>
    <div class="meeting-list-view">

      <modules-title class="title-position" titleName="项目会议">

        <template slot="btn">
          <el-button
            v-hasPermi="{v:['xiagnmu:transaction:add']}"
            type="primary" size="mini" @click="addClick">发起会议</el-button>
        </template>

      </modules-title>

      <div class="pj-content">

        <div class="screen-view">

          <el-form
            ref="queryForm"
            :model="screenData"
            :inline="true"
            label-width="68px"
          >

            <el-form-item label="会议类型">
              <el-select
                v-model="screenData.type"
                placeholder="请选择类型"
                size="small"
                @change="typeChange"
              >
                <el-option
                  v-for="dict in typeOptions"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>

            <el-form-item label="项目">
              <el-select
                v-model="screenData.project_id"
                placeholder="请选择项目"
                size="small"
                @change="projectChange"
              >
                <el-option
                  v-for="dict in projectOptions"
                  :key="dict.id"
                  :label="dict.name"
                  :value="dict.id"
                />
              </el-select>
            </el-form-item>

<!--            <el-form-item label="发起人">-->
<!--              <el-cascader-->
<!--                :show-all-levels="false"-->
<!--                v-model="screenData.value"-->
<!--                placeholder="请选择发起人"-->
<!--                :options="options11"-->
<!--                @change="handleChange"-->
<!--                filterable></el-cascader>-->
<!--            </el-form-item>-->

            <el-form-item label="关系">
              <el-select
                v-model="screenData.i_create"
                size="small"
                @change="handleChange"
              >
                <el-option
                  label="我发起的"
                  :value="1"
                />
                <el-option
                  label="我参与的"
                  :value="2"
                />
              </el-select>
            </el-form-item>

            <el-form-item label="会议名称">
              <el-input v-model="screenData.key" placeholder="请输入名称" clearable></el-input>
            </el-form-item>

            <el-form-item>

              <el-button type="primary" size="small" @click="handleQuery">搜索
              </el-button>
              <el-button plain size="small" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
        </div>

        <el-table
          @row-click="tableRowClick"
          size="medium"
          :data="tableData"
          border
          style="width: 100%">
<!--          <el-table-column-->
<!--            align="center"-->
<!--            prop="meet_no"-->
<!--            label="会议编号">-->
<!--          </el-table-column>-->
          <el-table-column
            align="center"
            prop="Name"
            label="会议名称">
          </el-table-column>
          <el-table-column
            align="center"
            label="会议类型">
            <template slot-scope="scope">
              <span v-if="scope.row.Type == 'Resolution'">决议会议</span>
              <span v-else-if="scope.row.Type == 'Ordinary'">普通会议</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="会议事务">
            <template slot-scope="scope">
              <span v-if="scope.row.ResolutionBusiness == 'ProjectResolution'">立项决议</span>
              <span v-else-if="scope.row.ResolutionBusiness == 'SchemeReview'">方案评审</span>
              <span v-else-if="scope.row.ResolutionBusiness == 'PlanReview'">计划评审</span>
              <span v-else-if="scope.row.ResolutionBusiness == 'TaskAcceptance'">任务验收</span>
              <span v-else-if="scope.row.ResolutionBusiness == 'ProjectAcceptance'">项目验收</span>
              <span v-else-if="scope.row.ResolutionBusiness == 'PeriodicReview'">阶段性评审</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="会议开始时间">
            <template slot-scope="scope">
              <span>{{scope.row.StartTime ? dateFormat1('yyyy-mm-dd HH:MM:SS',scope.row.StartTime) : ''}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            label="会议结束时间">
            <template slot-scope="scope">
              <span>{{scope.row.EndTime ? dateFormat1('yyyy-mm-dd HH:MM:SS',scope.row.EndTime) : ''}}</span>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="Creator.Name"
            label="发起人">
          </el-table-column>
          <el-table-column
            align="center"
            label="关联项目"
            prop="ProjectName">
          </el-table-column>
          <el-table-column
            align="center"
            label="关联任务"
            prop="TaskName">
          </el-table-column>
          <el-table-column
            align="center"
            label="会议状态">
            <template slot-scope="scope">
              <span v-if="scope.row.State == 'ToDo'">未开始</span>
              <span v-else-if="scope.row.State == 'Doing'">进行中</span>
              <span v-else-if="scope.row.State == 'Done'">已结束</span>
              <span v-else-if="scope.row.State == 'Cancel'">已取消</span>
            </template>
          </el-table-column>
        </el-table>

        <pagination style="display:flex;justify-content:flex-end;" :total="total" :page.sync="screenData.pager.skip"
                    :limit.sync="screenData.pager.limit" @pagination="getListData" />

      </div>

    </div>
</template>

<script>
  import {projectName} from "../../../../api/sampleInspection";

  export default {
        name: "index",
        data:function () {
            return{
                total:0,
                tableData:[],

                screenData:{
                    key:'',
                    type:'',
                    meeting_type:'',
                    project_id:'',
                    i_create:2,
                    creator_id:'',
                    value:[],
                    pager:{
                        limit:10,
                        skip:1,
                        OrderBy:'',
                        OrderMethod:-1
                    },
                },
                typeOptions:[
                    { label:'全部',value: "" },
                    { label:'普通会议',value: "Ordinary" },
                    { label:'决议会议',value: "Resolution" },
                ],
                affairOptions:[
                    { label:'全部',value: "" },
                    { label:'立项决议',value: "ProjectResolution" },
                    { label:'方案评审',value: "SchemeReview" },
                    { label:'计划评审',value: "PlanReview" },
                    { label:'任务验收',value: "TaskAcceptance" },
                    { label:'项目验收',value: "ProjectAcceptance" },
                    { label:'阶段性评审',value: "PeriodicReview" },
                ],
                projectOptions:[],
                createrOptions:[],
                options11:[]

            }
        },
        created:function(){
            this.getListData()

            this.$api.USER_GROUP_DEPARTMENT_LIST().then(res=>{
                if (res.code == 200){
                    res.data.data.forEach(mem=>{
                        mem.label = mem.name
                        mem.value = mem.id
                        if (!mem.children || !mem.children.length){
                            mem.leaf = true
                        }else if (mem.children.length) {
                            mem.children.forEach(item=>{
                                item.leaf = true;
                                item.value = item.id;
                                item.label = item.name;
                                item.department_id = item.id;
                            })
                        }
                    })
                    this.options11 = res.data.data;
                }else{
                    this.$message.error(res.msg)
                }
            });

            // projectName({
            //     project_status: [6, 7, 61, 62, 63, 64, 8, 9, 71, 72, 74, 75, 76, 77, 78, 79]
            // }).then(res=>{
            //     if (res.code === 200) {
            //
            //         if (res.data.data){
            //             res.data.data.forEach(item=>{
            //                 let phases = ""
            //                 if (item.project_phases_id == "1"){
            //                     phases = "临床前研究"
            //                 }else{
            //                     phases = "临床研究"
            //                 }
            //                 item.name = item.project_name + '(' + phases + ')'
            //             })
            //             this.projectOptions = res.data.data || [];
            //         }
            //     }
            // });

            this.$api.PROJECT_START_PROJECT_ALL().then(res=>{
                if (res.code === 200) {

                    if (res.data && res.data.data){
                        res.data.data.forEach(item=>{
                            let phases = ""
                            if (item.project_phases_id == "1"){
                                phases = "临床前研究"
                            }else{
                                phases = "临床研究"
                            }
                            item.name = item.project_name + '(' + phases + ')'
                        })
                        this.projectOptions = res.data.data || [];
                    }
                }
            });
        },
        methods:{
            tableRowClick:function(row, column, event){
                console.log(row, column, event)
                this.$comFun.goMeetingView(row.Id)
            },
            addClick:function(){
                this.$comFun.goMeetingAdd()
            },
            getListData:function(){
                this.$api.PROJECT_START_MEETING_LIST(this.screenData).then(res=>{
                    if (res.code == 200){
                        this.tableData = res.data.data;
                        this.total = res.data.total
                    }
                })
            },
            handleQuery:function () {
                this.screenData.pager.skip = 1;

                this.getListData()
            },
            resetQuery:function () {
                this.screenData.pager.skip = 1;
                this.screenData.meeting_type = '';
                this.screenData.i_create = 2;
                this.screenData.type = '';
                this.screenData.project_id = '';
                this.screenData.key = '';
                this.screenData.creator_id = '';
                this.screenData.value = []

                this.getListData()
            },
            handleChange:function(value){
                this.screenData.pager.skip = 1;

                this.getListData()
            },
            typeChange:function () {
                this.screenData.pager.skip = 1;

                this.getListData()
            },
            projectChange:function () {
                this.screenData.pager.skip = 1;

                this.getListData()
            },
            createrChange:function () {
                this.screenData.pager.skip = 1;

                this.getListData()
            }
        }
    }
</script>


<style lang="scss" scoped>
  @import "@/assets/scss/views/projectManagement/meeting/list.scss";
</style>
